<%@ page contentType="text/html; charset=UTF-8"%>

<%@ taglib prefix='c' uri='http://java.sun.com/jstl/core'%>
<%@taglib uri="/WEB-INF/tlds/struts-bean.tld" prefix="bean"%>
<%@ page import="org.acegisecurity.ui.AbstractProcessingFilter"%>
<%@ page import="org.acegisecurity.ui.webapp.AuthenticationProcessingFilter"%>
<%@ page import="org.acegisecurity.AuthenticationException"%>

<html>
	<head>
		<title>登陆</title>
		<link href="<%= request.getContextPath()%>/css/default.css" rel="stylesheet" type="text/css">
		<script type="text/javascript">
			function window_onload() {
				<% if(request.getParameter("reload") == null){ 
					session.invalidate();
				%>
				if(window.parent != null && window.name == 'main') {
					window.parent.location = "<%= request.getContextPath() %>/login.jsp?reload=1";
				} else if(window.opener != null) {
					window.opener.location = "<%= request.getContextPath() %>/login.jsp?reload=2";
					window.close();
				}
				<% } %>
			}
		</script>
	</head>
	<body onload="window_onload()">
		<c:if test="${not empty param.login_error}">
			<font color="red"> 用户名或者密码错误，轻重新录入！<BR>
				<BR> Reason: <%=((AuthenticationException) session.getAttribute(AbstractProcessingFilter.ACEGI_SECURITY_LAST_EXCEPTION_KEY)).getMessage()%> </font>
		</c:if>

		<form name='form1' action="<c:url value='j_acegi_security_check'/>" method="POST">
			<div align="left"></div>
			<table>
				<tr>
					<td colspan=2>
						<font size='-1'>请输入正确的用户名和密码！</font>
					</td>
				</tr>
				<tr>
					<td>
						用户:
					</td>
					<td>
						<input type='text' name='j_username' <c:if test="${not empty param.login_error}">value='<%= session.getAttribute(AuthenticationProcessingFilter.ACEGI_SECURITY_LAST_USERNAME_KEY) %>'</c:if>>
					</td>
				</tr>
				<tr>
					<td>
						密码:
					</td>
					<td>
						<input type='password' name='j_password'>
					</td>
				</tr>
				<tr>
					<td>
						<input type="checkbox" name="_acegi_security_remember_me">
					</td>
					<td>
						保存密码两周
					</td>
				</tr>
				<tr>
					<td colspan=2>
						<a href="index.jsp">使用匿名进入</a>
						&nbsp;&nbsp;&nbsp;
						<a href="<%= request.getContextPath() %>/common/security/User.do?webMethod=register">注册新用户</a>
					</td>
				</tr>
				<tr>
					<td colspan='2'>
						<input name="submit" type="submit" value='<bean:message key="form.submit" />'>
						<input name="reset" type="reset" value='<bean:message key="form.reset" />'>
					</td>
				</tr>
			</table>

		</form>

	</body>
	<script>
	form1.j_username.focus();
	</script>
</html>
